/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
    const { currentUser } = initialState ?? {};

    return {
        authentication: (route: { path: string }) => {

            return currentUser && currentUser.menu && currentUser.menu[route.path];
        },
        authAction: (path: string) => currentUser && currentUser.menu && currentUser.menu[path]
    };
}
